<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="common/include :: header('新增养修预约')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">拜访客户：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="customerId" id="customerId" th:onchange="get()">
                        <option th:text="请选择" value=""></option>
                        <option th:each="c:${customer}" th:text="${c.customerName}" th:value="${c.id}"></option>
                    </select>
                </div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">客户联系人：</label>
                <div class="col-sm-8">
                    <select class="form-control is-required"  name="linkmanId" id="linkmanId" th:with="type=${@dict.getType('cmi_service_type')}">
                        <option th:text="请选择" value=""></option>
                        <!--/*@thymesVar id="Linkmen" type=""*/-->
                        <!--<option th:each="Linkmen:${Linkmen}" th:text="${Linkmen.linkman}" th:value="${Linkmen.id}"></option>-->
                    </select>
                </div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">拜访方式：</label>
                <div class="col-sm-8">
                    <select class="form-control is-required" name="visitType" th:with="type=${@dict.getType('bus_visit_type')}">
                        <option th:text="请选择" value=""></option>
                        <option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
                    </select>
                </div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">拜访日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="visitDate" id="visitDate" class="form-control" placeholder="yyyy-MM-dd" type="text" th:value="${data}" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">拜访原因：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="visitReason" id="visitReason" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">交流情况：</label>
				<div class="col-sm-8">
					<textarea class="form-control" name="content" id="content" required></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="common/include :: footer" />
	<th:block th:include="common/include :: datetimepicker" />
	<script type="text/javascript">
        //设置时间格式
		$('input[name=visitDate]').datetimepicker({
			format:'yyyy-mm-dd',
			autoclose:true
		});

		var prefix = ctx + "/business/customerVisit";
		
		function submitHandler() {

	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-post-add').serialize());
	        }
	    }

	    function get() {
		    var $linkmanId = $("#linkmanId");
            $linkmanId.empty() //清空
            $linkmanId.append('<option value=" ">请选择</option>');
		    $.get(prefix + "/getLinkman?id=" + $("#customerId").val(),function (data) {
                console.log(data);
                $.each(data.data,function (index,ele) {
                    $linkmanId.append('<option value="' + ele.id + '">' + ele.linkman + '</option>')
                });
            });
        }
	</script>
</body>
</html>
